#include <iostream>
#include <string>
#include <cmath>

bool isPrime(int num) {
    if (num <= 1) {
        return false;
    }
    for (int i = 2; i <= sqrt(num); i++) {
        if (num % i == 0) {
            return false;
        }
    }
    return true;
}

int getNumber(std::string word) {
    if (word == "zero") {
        return 0;
    } else if (word == "one") {
        return 1;
    } else if (word == "two") {
        return 2;
    } else if (word == "three") {
        return 3;
    } else if (word == "four") {
        return 4;
    } else if (word == "five") {
        return 5;
    } else if (word == "six") {
        return 6;
    } else if (word == "seven") {
        return 7;
    } else if (word == "eight") {
        return 8;
    } else if (word == "nine") {
        return 9;
    } else {
        return -1;
    }
}

int main() {
    std::string input1, input2, input3;
    std::cin >> input1 >> input2 >> input3;

    int num1 = getNumber(input1);
    int num2 = getNumber(input2);
    int num3 = getNumber(input3);

    if (num1 == -1 || num2 == -1 || num3 == -1) {
        std::cout << "Wrong input" << std::endl;
        return 0;
    }

    int number = num1 * 100 + num2 * 10 + num3;

    if (number < 100 || number > 999) {
        std::cout << "Wrong input" << std::endl;
        return 0;
    }

    int primeNumber = number;
    while (true) {
        if (isPrime(primeNumber)) {
            std::cout << primeNumber << std::endl;
            break;
        }
        primeNumber++;
    }

    return 0;
}